/**
 * MyLinearLayout.java  [V 1.0.0]
 * classpath : com.example.eventhandletest.MyLinearLayout
 * zhangyw Create at 2015年3月30日 下午2:32:22
 */
package com.example.eventhandletest;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.LinearLayout;

/**
 * com.example.eventhandletest.MyLinearLayout
 * @author zhangyw
 * create at 2015年3月30日 下午2:32:22
 */
public class MyLinearLayout extends LinearLayout {
  private static final String TAG = "MyLinearLayout";

  /**
   * @param context
   */
  public MyLinearLayout(Context context) {
    super(context);
  }

  /**
   * @param context
   * @param attrs
   */
  public MyLinearLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  /**
   * @param context
   * @param attrs
   * @param defStyleAttr
   */
  public MyLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
  }

  /**
   * @param context
   * @param attrs
   * @param defStyleAttr
   * @param defStyleRes
   */
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  public MyLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
  }
  
  /* (non-Javadoc)
   * @see android.widget.LinearLayout#onDraw(android.graphics.Canvas)
   */
  @Override
  protected void onDraw(Canvas canvas) {
    Log.i("MyLinearLayout::"+getId(), "onDraw begin!");
    super.onDraw(canvas);
  }
  
  /* (non-Javadoc)
   * @see android.widget.LinearLayout#onLayout(boolean, int, int, int, int)
   */
  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
    Log.i("MyLinearLayout::"+getId(), "onLayout begin!");
    Log.i("MyLinearLayout::"+getId(), "output parameters:"+changed+","+l+","+t+","+r+","+b);
    super.onLayout(changed, l, t, r, b);
  }
  
  /* (non-Javadoc)
   * @see android.widget.LinearLayout#onMeasure(int, int)
   */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    Log.i("MyLinearLayout::"+getId(), "onMeasure begin!");
    Log.i("MyLinearLayout::"+getId(), "output parameters:"+MeasureSpec.getSize(widthMeasureSpec)+","+MeasureSpec.getSize(heightMeasureSpec));
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
  
  /* (non-Javadoc)
   * @see android.view.ViewGroup#dispatchDraw(android.graphics.Canvas)
   */
  @Override
  protected void dispatchDraw(Canvas canvas) {
    Log.i("MyLinearLayout::"+getId(), "dispatchDraw begin!");
    super.dispatchDraw(canvas);
  }
  
  /* (non-Javadoc)
   * @see android.view.ViewGroup#onInterceptTouchEvent(android.view.MotionEvent)
   */
  @Override
  public boolean onInterceptTouchEvent(MotionEvent ev) {
    Log.v("MyLinearLayout:"+getId(), "dispatchTouchEvent::"+" begin");
    boolean rst=super.onInterceptTouchEvent(ev);
    if(ev.getAction()==MotionEvent.ACTION_MOVE){
      rst=true;
    }
    Log.v("MyLinearLayout:"+getId(), "onInterceptTouchEvent::"+MotionEvent.actionToString(ev.getAction())+rst);
    return rst;
  }
  
  /* (non-Javadoc)
   * @see android.view.ViewGroup#dispatchTouchEvent(android.view.MotionEvent)
   */
  @Override
  public boolean dispatchTouchEvent(MotionEvent ev) {
    Log.v("MyLinearLayout:"+getId(), "dispatchTouchEvent::"+"begin");
    boolean rst=super.dispatchTouchEvent(ev);
    Log.v("MyLinearLayout:"+getId(), "dispatchTouchEvent::"+MotionEvent.actionToString(ev.getAction())+rst);
    return rst;
  }
  
  /* (non-Javadoc)
   * @see android.view.View#onTouchEvent(android.view.MotionEvent)
   */
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    Log.v("MyLinearLayout:"+getId(), "onTouchEvent::"+" begin");
    boolean rst=super.onTouchEvent(event);
    return rst;
  }
  
}
